﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class web_nhatuyendung : System.Web.UI.Page
{
    public string mess = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "Nhà tuyển dụng " + ConfigurationManager.AppSettings["centername"];
        if (Session["NTDuser"] != null)
        {
            if (Session["NTDuser"].ToString().Equals("Y"))
            {
                Response.Redirect("nhatuyendung_home.aspx");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/web/pages/dangkynhatuyendung.aspx");
    }
    protected void btn_dangnhap_Click(object sender, EventArgs e)
    {
        Common comm = new Common();
        NhaTuyenDungCommon ntdComm = new NhaTuyenDungCommon();
        if (Session["NTDuser"] == null)
        {
            Session["NTDuser"] = "N";
        }
       
        if (ntdComm.login(txt_tai_khoan.Text, txt_pass.Text))
        {

            DataRow userdtr = comm.getDataTable("select * from doanhnghiep_doanh_nghiep where tai_khoan = '" + comm.TextFormat(txt_tai_khoan.Text) + "' ").Rows[0];
            
                Session["NTDuser"] = "Y";
                Session["NTD_Active"] = userdtr["kich_hoat"]; 
                Session["NTDid"] = userdtr["ma_doanh_nghiep"];
                Session["NTDtenNTD"] = userdtr["ten_doanh_nghiep"];
                Session["NTDtaikhoan"] = userdtr["tai_khoan"];
        }
        if (Session["NTDuser"].ToString().Equals("Y"))
        {
            Response.Redirect("nhatuyendung_home.aspx");
        }
        else
        {
            mess = "Tài khoản đăng nhập không đúng hoặc đã bị chặn.";
        }
    }
}
